package hl.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ModelDriven;

import hl.pageModel.DataGrid;
import hl.pageModel.Json;
import hl.pageModel.MemberPhysical;
import hl.service.MemberPhysicalService;

@Namespace("/")
@Action(value = "memberPhysicalAction")
public class MemberPhysicalAction extends BaseAction implements ModelDriven<MemberPhysical> {

	MemberPhysical memberPhysical = new MemberPhysical();

	private MemberPhysicalService memberPhysicalService;

	@Override
	public MemberPhysical getModel() {
		return memberPhysical;
	}

	public MemberPhysicalService getMemberPhysicalService() {
		return memberPhysicalService;
	}

	@Autowired
	public void setMemberPhysicalService(MemberPhysicalService memberPhysicalService) {
		this.memberPhysicalService = memberPhysicalService;
	}


	public void add() {
		Json j = new Json();
		try {
			memberPhysicalService.save(memberPhysical);
			j.setSuccess(true);
			j.setMsg("增加成功");

		} catch (Exception e) {
			j.setMsg(e.getMessage());
		}
		super.writeJson(j);
	}

	public void getDatagrid() {
		DataGrid d = memberPhysicalService.getDatagrid(memberPhysical);
		super.writeJson(d);
	}

	
}
